package com.dolphinwang.imagecoverflow;

import ohos.agp.utils.Matrix;
import ohos.agp.utils.RectFloat;

/**
 * Created by dolphinWang on 2018/3/5.
 */
public class CoverFlowCell {
    /**
     * width
     */
    public int width;

    /**
     * height
     */
    public int height;

    /**
     * is OnTop
     */
    public boolean isOnTop;

    /**
     * showing Position
     */
    public int showingPosition;

    /**
     * index
     */
    public int index;

    /**
     * showing Rect
     */
    public RectFloat showingRect;

    public CoverFlowCell() {
        showingRect = new RectFloat();
    }

    /**
     * map Trans form
     *
     * @param transformer Matrix
     * @return boolean
     */
    public boolean mapTransform(Matrix transformer) {
        if (height == 0 || width == 0) {
            return false;
        }

        showingRect.top = 0;
        showingRect.left = 0;
        showingRect.right = width;
        showingRect.bottom = height;

        return transformer.mapRect(showingRect);
    }

    /**
     * Touch in Area (areaX,areaX)
     *
     * @param areaX float
     * @param areaY float
     * @return boolean
     */
    public boolean inTouchArea(float areaX, float areaY) {
        return showingRect.isInclude(areaX, areaY);
    }
}
